package com.artron.mediaartron.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.artron.baselib.base.BaseFragment;
import com.artron.mediaartron.R;
import com.artron.mediaartron.ui.fragment.made.PreviewFragment;

/**
 * Class description here
 *
 * @author doing
 * @version 1.0.0
 * @since 2017-10-11.
 */

public class PreviewActivity extends AppBaseActivity {

    public static final String FRAME_RESOURCE = "FrameResource";
    public static final String IMAGE_PATH = "ImagePath";
    public static final String HEIGHT = "Height";
    public static final String WIDTH = "Width";
    public static final String TYPE = "type";
    public static final String MATERIAL_ID = "MaterialId";


    public static void start(Context context, int frameResourceId, String path, float frameWidth
                                , float frameHeight, int type, String materialId) {
        Intent starter = new Intent(context, PreviewActivity.class);
        starter.putExtra(FRAME_RESOURCE, frameResourceId);
        starter.putExtra(IMAGE_PATH, path);
        starter.putExtra(HEIGHT, frameHeight);
        starter.putExtra(WIDTH, frameWidth);
        starter.putExtra(TYPE, type);
        starter.putExtra(MATERIAL_ID, materialId);
        context.startActivity(starter);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_general;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        int res = getIntent().getIntExtra(FRAME_RESOURCE, R.drawable.ic_frame_shape_type0);
        String path = getIntent().getStringExtra(IMAGE_PATH);
        float height = getIntent().getFloatExtra(HEIGHT, 500);
        float width = getIntent().getFloatExtra(WIDTH, 500);
        int type = getIntent().getIntExtra(TYPE, CustomSelectionActivity.POSTER);
        String materialId = getIntent().getStringExtra(MATERIAL_ID);
        BaseFragment fragment = PreviewFragment.newInstance(res, path, width, height, type, materialId);
        addFragment(R.id.General_content, fragment, false);
    }

    @Override
    protected void initActionBar() {
        mToolbar.setNavigationIcon(R.drawable.ic_back);
        int type = getIntent().getIntExtra(TYPE, CustomSelectionActivity.POSTER);
        if (type == CustomSelectionActivity.CUSTOM_MADE) {
            mTvTitle.setText("框画预览");
        } else {
            mTvTitle.setText("海报预览");
        }
        super.initActionBar();
    }
}
